/*
 * Copyright 2016 Huawei Technologies Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openo.nfvo.resmanagement.service.entity;

import org.apache.commons.lang3.StringUtils;
import org.openo.nfvo.resmanagement.common.util.JsonUtil;

import net.sf.json.JSONObject;

/**
 *
 * Virtualised infrastructure manager entity class.<br>
 * <p>
 * </p>
 *
 * @author
 * @version     NFVO 0.5  Sep 10, 2016
 */
public class VimEntity {

    /**
     * This field corresponds to the database column vim.ID
     *
     * @mbggenerated
     */
    private String id;

    /**
     * This field corresponds to the database column vim.ID
     *
     * @mbggenerated
     */
    private String name;

    /**
     * This method was generated by MyBatis Generator. This method returns the
     * value of the database column vim.ID
     *
     * @return the value of vim.ID
     */
    public String getId() {
        return id;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the
     * value of the database column vim.ID
     *
     * @param id
     * the value for vim.ID
     */
    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     *
     * To Entity.<br>
     *
     * @param jsonObject
     * @return
     * @since  NFVO 0.5
     */
    public static VimEntity toEntity(JSONObject jsonObject) {
        VimEntity vimEntity = new VimEntity();
        vimEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
        vimEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
        return vimEntity;
    }

    /**
     *
     * To String.<br>
     *
     * @return
     * @since   NFVO 0.5
     */
    public String toString() {
        JSONObject resJson = new JSONObject();
        resJson.put("id", StringUtils.trimToEmpty(this.getId()));
        resJson.put("name", StringUtils.trimToEmpty(this.getName()));
        return resJson.toString();
    }
}
